package com.whut.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.whut.model.*;
import com.whut.service.NewFuzzyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName newFuzzyController
 * @Auhtor chr
 * @Description 新模糊数学模块
 * @Date 2020/9/23 16:46
 **/
@Slf4j
@RestController
@RequestMapping("/newFuzzy")
public class NewFuzzyController {
    @Resource
    private NewFuzzyService newFuzzyService;
    /**
     * @Author chenhuanru
     * @Description //获取所有新模糊数学专家信息
     * @Date 19:08 2020-09-24 19:08:44
     * @Param [curPage, pageSize]
     * @return java.lang.Object
     **/
    @PostMapping("/getAllSpecialist")
    public Object getAllSpecialist(Integer curPage,Integer pageSize){
        return newFuzzyService.getAllSpecialist(curPage,pageSize);
    }
    /**
     * @Author chenhuanru
     * @Description //添加专家信息
     * @Date 19:09 2020-09-24 19:09:14
     * @Param [newspecialistinfo]
     * @return java.lang.String
     **/
    @PostMapping("/addSpecialInfo")
    public String addSpecialInfo(Newspecialistinfo newspecialistinfo){
        return newFuzzyService.addSpecialInfo(newspecialistinfo);
    }
    /**
     * @Author chenhuanru
     * @Description //更新专家信息
     * @Date 19:09 2020-09-24 19:09:40
     * @Param [newspecialistinfo]
     * @return java.lang.String
     **/
    @PostMapping("/updateNewSpecialInfo")
    public String updateNewSpecialInfo(Newspecialistinfo newspecialistinfo){
        return newFuzzyService.updateNewSpecialInfo(newspecialistinfo);
    }
    /**
     * @Author chenhuanru
     * @Description /获取判断矩阵（可以根据层次获取）
     * @Date 19:10 2020-09-24 19:10:04
     * @Param [specialistId, id3, nodeLevel]
     * @return java.lang.Object
     **/
    @PostMapping("/getAllNewJudgeInfo")
    public Object getAllNewJudgeInfo(int specialistId,int id3,int nodeLevel){
        return newFuzzyService.getAllNewJudgeInfo(specialistId,id3,nodeLevel);
    }
    @PostMapping("/getAllContractInfo")
    public Object getAllContractInfo(int specialistId){
        return newFuzzyService.getAllContractInfo(specialistId);
    }
    @PostMapping("/deleteContractInfoByMkey")
    public String deleteContractInfoByMkey(int mkey){
        return newFuzzyService.deleteContractInfoByMkey(mkey);
    }
    @PostMapping("/addContractSpecialInfo")
    public String addContractSpecialInfo(int client,int specialistId){
        return newFuzzyService.addContractSpecialInfo(client,specialistId);
    }
    /**
     * @Author chenhuanru
     * @Description //批量导入专家判断矩阵记录
     * @Date 19:10 2020-09-24 19:10:45
     * @Param [judgeInfos]
     * @return java.lang.String
     **/
    @PostMapping("/addNewJudgeInfos")
    public String addNewJudgeInfos(String judgeInfos){
        return newFuzzyService.addNewJudgeInfos(judgeInfos);
    }
    /**
     * @Author chenhuanru
     * @Description //根据专家id，层次 ，及父节点删除专家判断矩阵记录
     * @Date 19:11 2020-09-24 19:11:19
     * @Param [specialistId, id3, nodeLevel]
     * @return java.lang.String
     **/
    @PostMapping("/deleteByNewSpecialId")
    public String deleteByNewSpecialId(int specialistId,int id3,int nodeLevel){
        return newFuzzyService.deleteByNewSpecialId(specialistId,id3,nodeLevel);
    }
    /**
     * @Author chenhuanru
     * @Description //根据父节点，节点深度，获取子节点
     * @Date 19:14 2020-09-24 19:14:40
     * @Param [preNum, nodeDepth]
     * @return java.lang.String
     **/
    @PostMapping("/getChooseInfoForNewJudege")
    public Object getChooseInfoForNewJudege(int preNum,int nodeDepth){
        return newFuzzyService.getChooseInfoForNewJudege(preNum,nodeDepth);
    }
    /**
     * @Author chenhuanru
     * @Description //增加检查项对应的判断矩阵记录
     * @Date 20:35 2020-09-24 20:35:32
     * @Param [number, specialistId, id3, nodeLevel]
     * @return java.lang.String
     **/
    @PostMapping("/addNewJudgeItems")
    public String addNewJudgeItems(int number,int specialistId,int id3,int nodeLevel){
        return newFuzzyService.addNewJudgeItems(number,specialistId,id3,nodeLevel);
    }

    /**
     * @Author chenhuanru
     * @Description //编辑专家判断矩阵
     * @Date 10:01 2020-09-25 10:01:10
     * @Param [newjudgeinfo]
     * @return java.lang.String
     **/
    @PostMapping("/editNewJudgeInfo")
    public String editNewJudgeInfo(Newjudgeinfo newjudgeinfo){
        return newFuzzyService.editNewJudgeInfo(newjudgeinfo);
    }
    /**
     * @Author chenhuanru
     * @Description //删除检查项
     * @Date 15:21 2020-09-26 15:21:01
     * @Param [number, specialistId, id3, nodeLevel]
     * @return java.lang.String
     **/
    @PostMapping("/deleteSelectedItem")
    public String deleteSelectedItem(int number,int specialistId,int id3,int nodeLevel){
        return newFuzzyService.deleteSelectedItem(number,specialistId,id3,nodeLevel);
    }
    /**
     * @Author chenhuanru
     * @Description //根据专家id删除专家信息
     * @Date 15:22 2020-09-26 15:22:47
     * @Param [mkey]
     * @return java.lang.String
     **/
    @PostMapping("/deleteSpecialById")
    public String deleteSpecialById(int mkey){
        return newFuzzyService.deleteSpecialById(mkey);
    }
    /**
     * @Author chenhuanru
     * @Description //根据专家id删除隶属度矩阵记录
     * @Date 16:14 2020-09-26 16:14:47
     * @Param [specialistId]
     * @return java.lang.String
     **/
//    @PostMapping("/deleteNewMemberShipInfo")
//    public String deleteNewMemberShipInfoBySpecialId(){
//        return newFuzzyService.deleteNewMemberShipInfo();
//    }

    /**
     * @Author chenhuanru
     * @Description //批量插入专家隶属度矩阵（废弃）
     * @Date 16:19 2020-09-26 16:19:21
     * @Param [memberShipInfos]
     * @return java.lang.String
     **/
    @PostMapping("/addNewAllMemberShipInfo")
    public String addNewAllMemberShipInfo(String memberShipInfos){
        return newFuzzyService.addNewAllMemberShipInfo(memberShipInfos);
    }
    /**
     * @Author chenhuanru
     * @Description //判断矩阵一致性检验
     * @Date 16:49 2020-09-26 16:49:51
     * @Param [specialistId, id3, nodeLevel]
     * @return java.lang.Float
     **/
    @PostMapping("/newConsistCheck")
    public Float newConsistCheck(int specialistId,int id3,int nodeLevel){
        return newFuzzyService.newConsistCheck(specialistId,id3,nodeLevel);
    }
    /**
     * @Author chenhuanru
     * @Description //计算模糊数学结果（新的模型不计算专家权重）
     * @Date 18:52 2020-10-05 18:52:13
     * @Param [checkId, operator, calcDepth]
     * @return java.lang.Object
     **/
    @PostMapping("/allNewJudgeResult")
    public Object getAllNewJudgeResult(int checkId,int operator,int calcDepth,int firstId){
        return newFuzzyService.getAllNewJudgeResult(checkId, operator, calcDepth,firstId);
    }

    /**
     * @Author chenhuanru
     * @Description //计算安全得分
     * @Date 10:13 2020-10-19 10:13:43
     * @Param [fuzzyConclusion]
     * @return float
     **/
    @PostMapping("/calcPoint")
    public float calcPoint (String fuzzyConclusion){
        JSONArray list = JSON.parseArray(fuzzyConclusion);
        List<Float> list1 = JSONObject.parseArray(list.toJSONString(),Float.class);
        return newFuzzyService.calcPoint(list1);
    }
    /**
     * @Author chenhuanru
     * @Description //获取未废弃的体系检查项
     * @Date 15:12 2020-11-18 15:12:31
     * @Param [nodeDepth, preNum]
     * @return java.util.List<java.lang.Object>
     **/
    @PostMapping("/getUsedItemByDepth")
    public List<Object> getUsedItemByDepth (int nodeDepth,int preNum){
        return newFuzzyService.getUsedItemByDepth(nodeDepth,preNum);
    }

    /**
     * @Author chenhuanru
     * @Description //根据target获取合并项
     * @Date 16:24 2020-11-18 16:24:42
     * @Param [targets]
     * @return java.util.List<java.lang.String>
     **/
    @PostMapping("/getAllCombinedTerms")
    public List<Integer> getAllCombinedTerms (Integer[] targets){
        return newFuzzyService.getAllCombinedTerms(targets);
    }

    @PostMapping("/getCombinedTermsByTarget")
    public List<ParPrefixSystem> getCombinedTermsByTarget (Integer target){
        return newFuzzyService.getCombinedTermsByTarget(target);
    }

    @PostMapping("/getNewItemByDepth")
    public List<Object> getNewItemByDepth(int nodeDepth,int preNum) {
        return newFuzzyService.getNewItemByDepth(nodeDepth,preNum);
    }
    /**
     * @Author yya
     * @Description //根据专家id得到隶属度矩阵记录
     * @Date 16:14 2020-08-07 16:14:47
     * @Param [specialistId]
     * @return java.lang.String
     **/
    @PostMapping("/getAllNewMembership")
    public Object getAllNewMembership(Integer specialistId){
        return newFuzzyService.getAllNewMembership(specialistId);
    }
    /**
     * @Author yya
     * @Description //增加隶属度矩阵记录
     * @Date 16:14 2020-08-07 16:14:47
     * @Param [specialistId]
     * @return java.lang.String
     **/
    @PostMapping("/addNewmemberShipInfo")
    public String addMemberShipInfo(Newmembershipinfo newmembershipinfo) {
        newFuzzyService.addNewmemberShipInfo(newmembershipinfo);
        return "success";
    }
    /**
     * @Author yya
     * @Description //删除隶属度矩阵记录
     * @Date 16:14 2020-08-07 16:14:47
     * @Param [specialistId]
     * @return java.lang.String
     **/
    @PostMapping("/deleteNewmemberShipInfo")
    public String deleteNewmemberShipInfo(Integer mkey) {
        newFuzzyService.deleteNewmemberShipInfo(mkey);
        return "success";
    }
    /**
     * @Author yya
     * @Description //修改隶属度矩阵记录
     * @Date 16:14 2020-08-07 16:14:47
     * @Param [specialistId]
     * @return java.lang.String
     **/
    @PostMapping("/editNewmemberShipInfo")
    public String editNewmemberShipInfo(Newmembershipinfo newmembershipinfo) {
        newFuzzyService.editNewmemberShipInfo(newmembershipinfo);
        return "success";
    }

}
